package com.yiyang.controller;

import com.yiyang.domain.Result;
import com.yiyang.domain.ResultPage;
import com.yiyang.domain.dto.CustomerDto;
import com.yiyang.domain.po.Customer;
import com.yiyang.domain.vo.CustomerVo;
import com.yiyang.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    @GetMapping("/listKhxxPage")
    public Result<ResultPage<CustomerVo>> listKhxxPage(CustomerDto customerDto){
        ResultPage<CustomerVo> customerVoResultPage = customerService.listKhxxPage(customerDto);
        return Result.success(customerVoResultPage);
    }

    @PostMapping("/rzdj")
    public Result rzdj(@RequestBody Customer customer){
        customerService.rzdj(customer);
        return Result.success();
    }

    @PutMapping("/editKhxx")
    public Result editKhxx(@RequestBody Customer customer){
        customerService.editKhxx(customer);
        return Result.success();
    }

    @DeleteMapping("/remove")
    public Result removeCustomer(Integer id,Integer bedId){
        customerService.removeCustomer(id,bedId);
        return Result.success();
    }
}
